package com.socket.serializableTest;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * PetServer--bdqnPractice
 *
 * @author: Jovi
 * @createTime: 2017-09-14 13:43
 **/
public class PetServer {

    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(9092);

        Socket socket ;

        int num =0;

        while (true) {
            socket = ss.accept();
            ThreadSocket ts = new ThreadSocket(socket);
            ts.run();
            num++;
            System.out.println("有"+num+"只宠物在本店注册");

            InetAddress ia = socket.getInetAddress();
            String ip = ia.getHostAddress();
            System.out.println("本宠物主人的IP为：" + ip);
            String host = ia.getHostName();
            System.out.println("本宠物主人的主机名为：" + host);
        }
    }
}
